function success(ctx, msg = 'ok', data = []) {
  ctx.body = JSON.stringify({msg, data, code: 1000})
}

function fail(ctx, msg, code = 1001, data = []) {
  ctx.body = JSON.stringify({msg, data, code: 1000})
}

function routeFn(f) {
  return async function(ctx, next) {
    const rs = await f(ctx, next)
    ctx.body = rs
  }
}

module.exports = {success, fail, routeFn}
